<link rel="stylesheet" type="text/css" href="{$atplPath}skin/house_pingtai.css" />

<style>
	.ml0{margin-left: 0px!important;}
	.mw180{min-width: 180px!important;}
	.bw80{width: 80%!important;}
	.pr30{padding-right: 30px!important;}
	.ml190{margin-left: 190px!important;} 
</style>
<form id="myForm">
<div class="wrapper_house clearfix" id="app">
	<div class="col_main">
		<div class="main_wrap ml0">
		<div class="inner_sub_box">
		<div class="hd">楼盘基本资料<span class="bitian">(必填)</span></div>
		<div class="tips-h1" v-if="isfabu"><div class="tip">提示：新创建的楼盘默认为[下线]状态，建议您在完善资料后在进行上线操作</div></div>

		
			<input type="hidden" name="Loupanid" v-model="Loupanid" />
			<ul class="ul-form clearfix">
				<li>
					<span class="txt">楼盘名称：</span>
					<div class="con">
						<input type="text" name="Chrloupan" v-model="Chrloupan" placeholder="输入楼盘名称" class="int inp-form-sz inp3">  
					</div>
				</li>
				<li>
					<span class="txt">楼盘位置：</span>
					<div class="con">
						<input type="hidden" name="Quyuid" id="Quyuid" v-model="Quyuid" />
						<input type="hidden" name="Diduanid" id="Diduanid" v-model="Diduanid" />
						<div class="sel_box" @mouseenter="QuyuidShow=true" @mouseleave="QuyuidShow=false">{{QuyuidName}}<i class="ico"></i>
							<div class="sel_po" v-show="!!QuyuidShow">
								<item-select v-for="tag in QuyuidList" :key="tag.Categoryid" :tag="tag" forid="Quyuid" fortxt="QuyuidName" fotaction="QuyuidShow" is2="Diduanid"></item-select>
							</div>
						</div><div class="sel_box" @mouseenter="if(DiduanidList.length!='0') DiduanidShow=true" @mouseleave="DiduanidShow=false">{{DiduanidName}}<i class="ico"></i>
							<div class="sel_po" v-show="!!DiduanidShow">
								<item-select v-for="tag in DiduanidList" :key="tag.Categoryid" :tag="tag" forid="Diduanid" fortxt="DiduanidName" fotaction="DiduanidShow" is2=""></item-select>
							</div>
						</div><input type="text" name="Chraddress" v-model="Chraddress" placeholder="详细地址" class="int inp-form-sz inp1 inp3"><a href="javascript:void(0)" class="a-map" onClick="return biaozhu_2018();"></a>
						<input type="hidden" name="Loupan_x" v-model="Shop_x">
						<input type="hidden" name="Loupan_y" v-model="Shop_y">
						<input type="hidden" name="Loupan_z" v-model="Shop_z">
					</div>
				</li>
				<li>
					<span class="txt">封面图片：</span>
					<div class="con up_img">
						<input type="hidden" name="Filepath" v-model="Filepath" />
						<span class="po_re" v-show="Filepath!=''"><img :src="'../'+Filepath" /><span class="reup" @click="reupload('Filepath')">重新上传</span></span>
						<span class="" v-show="Filepath==''"><iframe name="ifm_upload" frameborder="0" width="100%" height="100" scrolling="no" src="/kindeditor/upload_one.aspx?action=5&type=Filepath&table_id=house&reqfile=upload_bm.aspx" style="vertical-align:top;"></iframe></span>
						<span class="zhu1 zhu2">上传一张封面图片，最佳尺寸：220像素x164像素</span>
					</div>
				</li>

				<li>
					<span class="txt">楼盘亮点：</span>
					<div class="con">
						<input type="text" name="Biaoyu" v-model="Biaoyu" placeholder="请用一句话描述" class="int inp-form-sz inp3">  
						
					</div>
				</li>
				<li>
					<span class="txt">房屋类型：</span>
					<div class="con">
						<!--<input type="hidden" name="Categoryids" v-model="Leixing" />
						<div class="sel_box" @mouseenter="LeixingShow=true" @mouseleave="LeixingShow=false">{{LeixingName}}<i class="ico"></i>
							<div class="sel_po" v-show="!!LeixingShow">
								<item-select v-for="tag in LeixingList" :key="tag.Categoryid" :tag="tag" forid="Leixing" fortxt="LeixingName" fotaction="LeixingShow" is2=""></item-select>
							</div>
						</div>-->
						<item-checkbox v-for="(tag, index) in CategoryidsList" :key="tag.Categoryid" :tag="tag" :index="index" forname="Categoryids"></item-checkbox>
					</div>
				</li>
				<li>
					<span class="txt">开发商：</span>
					<div class="con">
						<input type="text" name="Chrsupply" v-model="Chrsupply" placeholder="请输入开发商名称" class="int inp-form-sz inp7">   
					</div>
				</li>

				<li>
					<span class="txt">售楼电话：</span> 
					<div class="con">
						<input type="text" name="Shouloutel" v-model="Shouloutel" placeholder="请输入售楼处电话" class="int inp-form-sz inp7">   
					</div>
				</li>
				<li>
					<span class="txt">特色标签：</span>
					<div class="con">
						<label class="lab2" :class="Tese_allin?'on':''" @click="selectAllTag('Tese',false)">全选</label>
						<item-tese v-for="(tag, index) in TeseList" :key="tag.Categoryid" :tag="tag" :index="index" :Ccid="-1" forname="Tese"></item-tese><a href="teseconfig" class="lab2 add2">添加/管理标签</a>
					</div>
				</li>
				<li>
					<span class="txt">销售状态：</span>
					<div class="con">
						<input type="hidden" name="SaleStatus" v-model="SaleStatus">
						<label class="open_close2" :class="SaleStatus==0?'on':''" @click="SaleStatus=0">待售</label>
						<label class="open_close2" :class="SaleStatus==1?'on':''" @click="SaleStatus=1">在售</label>
						<label class="open_close2" :class="SaleStatus==2?'on':''" @click="SaleStatus=2">售罄</label>
					</div>
				</li>

				<li>
					<span class="txt">显示排序：</span>
					<div class="con">
						<input type="text" name="Intorder" v-model="Intorder" placeholder="请输入" class="int inp-form-sz inp2">
						<span class="zhu1 zhu2">数字越大越靠前！</span>  
					</div>
				</li>

			</ul>
			<input type="submit" value="确认提交" class="btn-form ani">
		
	</div>
	</div>
</div>
 
</div>
</form>
<div class="map_iframe" id="map_iframe" data-isloaded="0" style="display:none;">
	<div id="allmap"></div>
	<div class="bottom">
		<div class="left"><input type="text" class="search_txt" id="search_txt" /><button type="button" class="search_btn" onClick="get_point()">查找</button></div>
		<div class="right"><a href="javascript:void(0);" onClick="return bz_ok();" class="btn_blue">确定标注</a>　<a href="javascript:void(0);" onClick="return bz_cancel();" class="btn_gray">取消</a></div>
	</div>
</div>
<script type="text/javascript" src="//api.map.baidu.com/api?v=2.0&ak={$ggmapkey}"></script>
<script type="text/javascript" src="//developer.baidu.com/map/jsdemo/demo/convertor.js"></script>
<script src="{$atplPath}js/jquery-1.10.2.min.js"></script>
<script src="{$atplPath}js/purl.js"></script>
<script src="{$atplPath}js/vue/axios.min.js"></script>
<script src="{$atplPath}js/vue/es6-promise.auto.min.js"></script>
<script src="{$atplPath}js/vue/vue.min.js"></script>
<script src="{$atplPath}js/vue/houseCategory.js"></script>
<script src="{$atplPath}js/vue/form_2018.js"></script>

<script>
window['CITY'] = '{$city}';
var mypage = new Vue({
	el: '#app',
	components: {
		'item-s': Item_s,
		'item-tag':Item_tag,
		'item-tese':Item_tese,
		'item-select':Item_select,
		'item-checkbox':Item_checkbox
	},
	data: {
		isfabu:false,
		Chrloupan:'',
		Filepath:'',
		Loupanid:'',
		Biaoyu :'',
		Chrsupply:'',
		Shouloutel:'',
		Intorder:'0',
		SaleStatus:'',
		//选择器
		Categoryids:[],//选中数据
		CategoryidsList:[],//所有条目
		QuyuidShow:false,
		Quyuid:'0',
		QuyuidName:'请选择区域',
		QuyuidList:[],
		DiduanidShow:false,
		Diduanid:'0',
		DiduanidName:'请选择地段',
		DiduanidList:[],
		//小区搜索
		Chraddress:'',
		Shop_x:0,
		Shop_y:0,
		Shop_z:0,
		
		//标签选择
		Tese:'',
		Tese_allin:false,
		TeseList:[]
		
	},
	methods:{
		reupload:function(forname){
			var that = this;
			that[forname]='';
		},
		getData:function(sid){
			var that = this;
			var url = '/api/LouPan/GetLoupanInfo?loupanid='+sid+'&timer='+Date.parse(new Date());
			axios.get(url).then(function(res){
				if(typeof res.data.iserror !== 'undefined' && res.data.iserror === 1){
					return;
				}
				var Data = res.data;
				Data.Shop_x = Data.X;
				Data.Shop_y = Data.Y;
				
				for(var k in Data){
					that[k] = Data[k];
				}
				that.setmobileSelect();
			}).catch(function(err){that.ifLoadding = false;alert('抱歉，加载失败了！');});
		},
		getTagData:function(styleid,sid,forname){
			var that = this,url='';
			if(styleid === '0'){
				url = '/api/HouseCategory/SearchHouseCategory';
				$.ajax({'url':url,dataType:'json',data:{'Category':sid,'timer':Math.random()},success:function(data){
					
				}});
			}else{
				url = '/api/Category/SearchCategory';
				$.ajax({'url':url,dataType:'json',data:{'Category':sid,'timer':Math.random()},success:function(data){
					var i=0,len=data[sid].length,arr=[];
					if(that[forname]!==''){
						arr = that[forname];
					}
					for(;i<len;i++){
						for(var k = 0;k<arr.length;k++){
							if(arr[k] == data[sid][i].Categoryid){
								data[sid][i].checked=true;
							}
						}
						that[forname+'List'].push(data[sid][i]);
					}
				}});
			}
		},
		setmobileSelect:function(){
			var that=this;
			that.getTagData('1','31','Tese');
			getHouseCatJSON('1','0','Quyuid',setQuyuSel_vue);
			getHouseCatJSON('1','12','Categoryids',setCheckbox_vue);
		},
		selectAllTag:function(forname){
			var that = this;
			var arr = that[forname+'List'];
			that[forname+'_allin'] = !that[forname+'_allin'];
			for(var i=0;i<arr.length;i++){
				Vue.set(arr[i], 'checked', that[forname+'_allin']);
			}
		}
	},
	created:function(){
		var that = this;
		var url_obj = $.url(window.location.href).param();
		var formUrl = '';
		if(!!url_obj['Loupanid'] && url_obj['Loupanid']!==''){
			that.getData(url_obj['Loupanid']);
			formUrl = 'LouPanBaseInfoUpdate';
			that.isfabu = false;
		}else{
			formUrl = 'LouPanSubbmit';
			that.setmobileSelect();
			that.isfabu = true;
		}
		
		$('#myForm').loadForm('/api/LouPan/'+formUrl,function(myForm){
			if(myForm[0].Chrloupan.value===''){
				MSGwindowShow('house','0','请输入楼盘名称！','','');
				return false;
			}
			if(myForm[0].Quyuid.value==='0'||myForm[0].Quyuid.value===''){
				MSGwindowShow('house','0','请选择'+mypage.loupantit+'所在的区域！','','');
				return false;
			}
			if(myForm[0].Chraddress.value===''){
				MSGwindowShow('house','0','请输入'+mypage.loupantit+'详细地址！','','');
				return false;
			}
			if(myForm[0].Loupan_x.value==='0'){
				MSGwindowShow('house','0','请给'+mypage.loupantit+'标注一下地理位置哦！','','');
				return false;
			}
			return true;
		},function(myForm,data){
			MSGwindowShow('house','1','提交成功！','loupan','');
			
		});
	},
});
function uploadsuccess(sid,surl,num){
	mypage[num] = surl;
}
</script>